﻿using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.Common;
using System.Collections;

namespace DALL.LibrarySys
{
    public class T_PUB_LIBRARYOUTMATERIAL
    {
        public T_PUB_LIBRARYOUTMATERIAL()
        { }

        /// <summary>
        /// 添加出库申请元素
        /// </summary>
        public void AddMaterials(Model.LibrarySys.T_PUB_LIBRARYOUT libraryout, IList<Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL> materiallist)
        {
            ArrayList strArry = new ArrayList();

            #region 添加出库单
            StringBuilder strSql = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();
            if (libraryout.ID != null)
            {
                strSql1.Append("ID,");
                strSql2.Append("'" + libraryout.ID + "',");
            }
            if (libraryout.BRANCH_ID != null)
            {
                strSql1.Append("BRANCH_ID,");
                strSql2.Append("" + libraryout.BRANCH_ID + ",");
            }
            if (libraryout.LIBRARY_ID != null)
            {
                strSql1.Append("LIBRARY_ID,");
                strSql2.Append("" + libraryout.LIBRARY_ID + ",");
            }
            if (libraryout.APPLICANT != null)
            {
                strSql1.Append("APPLICANT,");
                strSql2.Append("" + libraryout.APPLICANT + ",");
            }
            if (libraryout.APPLY_TIMEOUT != null)
            {
                strSql1.Append("APPLY_TIMEOUT,");
                strSql2.Append("'" + libraryout.APPLY_TIMEOUT + "',");
            }
            if (libraryout.REAL_TIMEOUT != null)
            {
                strSql1.Append("REAL_TIMEOUT,");
                strSql2.Append("'" + libraryout.REAL_TIMEOUT + "',");
            }
            if (libraryout.PLAN_TIMEIN != null)
            {
                strSql1.Append("PLAN_TIMEIN,");
                strSql2.Append("'" + libraryout.PLAN_TIMEIN + "',");
            }
            if (libraryout.REAL_TIMEIN != null)
            {
                strSql1.Append("REAL_TIMEIN,");
                strSql2.Append("'" + libraryout.REAL_TIMEIN + "',");
            }
            if (libraryout.STATE != null)
            {
                strSql1.Append("STATE,");
                strSql2.Append("'" + libraryout.STATE + "',");
            }
            if (libraryout.REMARK != null)
            {
                strSql1.Append("REMARK,");
                strSql2.Append("'" + libraryout.REMARK + "',");
            }
            if (libraryout.TITEL != null)
            {
                strSql1.Append("TITEL,");
                strSql2.Append("'" + libraryout.TITEL + "',");
            }
            if (libraryout.APPLY_TIME != null)
            {
                strSql1.Append("APPLY_TIME,");
                strSql2.Append("'" + libraryout.APPLY_TIME + "',");
            }
            if (libraryout.ORDER_ID != null)
            {
                strSql1.Append("ORDER_ID,");
                strSql2.Append("" + libraryout.ORDER_ID + ",");
            }
            if (libraryout.NOTATION != null)
            {
                strSql1.Append("NOTATION,");
                strSql2.Append("'" + libraryout.NOTATION + "',");
            }
            if (libraryout.APPROVER != null)
            {
                strSql1.Append("APPROVER,");
                strSql2.Append("" + libraryout.APPROVER + ",");
            }
            if (libraryout.APPLICANT_NAME != null)
            {
                strSql1.Append("APPLICANT_NAME,");
                strSql2.Append("'" + libraryout.APPLICANT_NAME + "',");
            }
            if (libraryout.APPROVER_NAME != null)
            {
                strSql1.Append("APPROVER_NAME,");
                strSql2.Append("'" + libraryout.APPROVER_NAME + "',");
            }
            strSql.Append("insert into T_PUB_LIBRARYOUT(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strArry.Add(strSql);
            #endregion

            #region 添加出库单材料
            foreach (Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL item in materiallist)
            {
                StringBuilder strSqls = new StringBuilder();
                StringBuilder strSqls1 = new StringBuilder();
                StringBuilder strSqls2 = new StringBuilder();
                if (item.LIBRARYOUTID != null)
                {
                    strSqls1.Append("LIBRARYOUTID,");
                    strSqls2.Append("'" + item.LIBRARYOUTID + "',");
                }
                if (item.MATERIAL_ID != null)
                {
                    strSqls1.Append("MATERIAL_ID,");
                    strSqls2.Append("" + item.MATERIAL_ID + ",");
                }
                if (item.MATERIAL_NAME != null)
                {
                    strSqls1.Append("MATERIAL_NAME,");
                    strSqls2.Append("'" + item.MATERIAL_NAME + "',");
                }
                if (item.NUM != null)
                {
                    strSqls1.Append("NUM,");
                    strSqls2.Append("" + item.NUM + ",");
                }
                if (item.MATERIAL_STATE != null)
                {
                    strSqls1.Append("MATERIAL_STATE,");
                    strSqls2.Append("'" + item.MATERIAL_STATE + "',");
                }
                if (item.TIMEIN != null)
                {
                    strSqls1.Append("TIMEIN,");
                    strSqls2.Append("'" + item.TIMEIN + "',");
                }
                strSqls.Append("insert into T_PUB_LIBRARYOUTMATERIAL(");
                strSqls.Append(strSqls1.ToString().Remove(strSqls1.Length - 1));
                strSqls.Append(")");
                strSqls.Append(" values (");
                strSqls.Append(strSqls2.ToString().Remove(strSqls2.Length - 1));
                strSqls.Append(")");
                strSqls.Append(";select @@IDENTITY");
                strArry.Add(strSqls);
            }
            #endregion

            DBHelper.ExecuteSqlTran(strArry);
        }

        /// <summary>
        /// 编辑出库申请元素
        /// </summary>
        public void EditMaterials(Model.LibrarySys.T_PUB_LIBRARYOUT libraryout, IList<Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL> addList, IList<Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL> editList)
        {
            ArrayList strArry = new ArrayList();

            #region 更新出库单
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_PUB_LIBRARYOUT set ");
            if (libraryout.BRANCH_ID != null)
            {
                strSql.Append("BRANCH_ID=" + libraryout.BRANCH_ID + ",");
            }
            else
            {
                strSql.Append("BRANCH_ID= null ,");
            }
            if (libraryout.LIBRARY_ID != null)
            {
                strSql.Append("LIBRARY_ID=" + libraryout.LIBRARY_ID + ",");
            }
            else
            {
                strSql.Append("LIBRARY_ID= null ,");
            }
            if (libraryout.APPLICANT != null)
            {
                strSql.Append("APPLICANT=" + libraryout.APPLICANT + ",");
            }
            else
            {
                strSql.Append("APPLICANT= null ,");
            }
            if (libraryout.APPLY_TIMEOUT != null)
            {
                strSql.Append("APPLY_TIMEOUT='" + libraryout.APPLY_TIMEOUT + "',");
            }
            else
            {
                strSql.Append("APPLY_TIMEOUT= null ,");
            }
            if (libraryout.REAL_TIMEOUT != null)
            {
                strSql.Append("REAL_TIMEOUT='" + libraryout.REAL_TIMEOUT + "',");
            }
            else
            {
                strSql.Append("REAL_TIMEOUT= null ,");
            }
            if (libraryout.PLAN_TIMEIN != null)
            {
                strSql.Append("PLAN_TIMEIN='" + libraryout.PLAN_TIMEIN + "',");
            }
            else
            {
                strSql.Append("PLAN_TIMEIN= null ,");
            }
            if (libraryout.REAL_TIMEIN != null)
            {
                strSql.Append("REAL_TIMEIN='" + libraryout.REAL_TIMEIN + "',");
            }
            else
            {
                strSql.Append("REAL_TIMEIN= null ,");
            }
            if (libraryout.STATE != null)
            {
                strSql.Append("STATE='" + libraryout.STATE + "',");
            }
            else
            {
                strSql.Append("STATE= null ,");
            }
            if (libraryout.REMARK != null)
            {
                strSql.Append("REMARK='" + libraryout.REMARK + "',");
            }
            else
            {
                strSql.Append("REMARK= null ,");
            }
            if (libraryout.TITEL != null)
            {
                strSql.Append("TITEL='" + libraryout.TITEL + "',");
            }
            else
            {
                strSql.Append("TITEL= null ,");
            }
            if (libraryout.APPLY_TIME != null)
            {
                strSql.Append("APPLY_TIME='" + libraryout.APPLY_TIME + "',");
            }
            else
            {
                strSql.Append("APPLY_TIME= null ,");
            }
            //if (libraryout.ORDER_ID != null)
            //{
            //    strSql.Append("ORDER_ID=" + libraryout.ORDER_ID + ",");
            //}
            //else
            //{
            //    strSql.Append("ORDER_ID= null ,");
            //}
            //if (libraryout.NOTATION != null)
            //{
            //    strSql.Append("NOTATION='" + libraryout.NOTATION + "',");
            //}
            //else
            //{
            //    strSql.Append("NOTATION= null ,");
            //}
            //if (libraryout.APPROVER != null)
            //{
            //    strSql.Append("APPROVER=" + libraryout.APPROVER + ",");
            //}
            //else
            //{
            //    strSql.Append("APPROVER= null ,");
            //}
            if (libraryout.APPLICANT_NAME != null)
            {
                strSql.Append("APPLICANT_NAME='" + libraryout.APPLICANT_NAME + "',");
            }
            else
            {
                strSql.Append("APPLICANT_NAME= null ,");
            }
            //if (libraryout.APPROVER_NAME != null)
            //{
            //    strSql.Append("APPROVER_NAME='" + libraryout.APPROVER_NAME + "',");
            //}
            //else
            //{
            //    strSql.Append("APPROVER_NAME= null ,");
            //}
            int n = strSql.ToString().LastIndexOf(",");
            strSql.Remove(n, 1);
            strSql.Append(" where ID='" + libraryout.ID + "' ");
            strArry.Add(strSql);
            #endregion

            #region 添加出库单材料
            foreach (Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL item in addList)
            {
                StringBuilder strSqls = new StringBuilder();
                StringBuilder strSqls1 = new StringBuilder();
                StringBuilder strSqls2 = new StringBuilder();
                if (item.LIBRARYOUTID != null)
                {
                    strSqls1.Append("LIBRARYOUTID,");
                    strSqls2.Append("'" + item.LIBRARYOUTID + "',");
                }
                if (item.MATERIAL_ID != null)
                {
                    strSqls1.Append("MATERIAL_ID,");
                    strSqls2.Append("" + item.MATERIAL_ID + ",");
                }
                if (item.MATERIAL_NAME != null)
                {
                    strSqls1.Append("MATERIAL_NAME,");
                    strSqls2.Append("'" + item.MATERIAL_NAME + "',");
                }
                if (item.NUM != null)
                {
                    strSqls1.Append("NUM,");
                    strSqls2.Append("" + item.NUM + ",");
                }
                if (item.MATERIAL_STATE != null)
                {
                    strSqls1.Append("MATERIAL_STATE,");
                    strSqls2.Append("'" + item.MATERIAL_STATE + "',");
                }
                if (item.TIMEIN != null)
                {
                    strSqls1.Append("TIMEIN,");
                    strSqls2.Append("'" + item.TIMEIN + "',");
                }
                strSqls.Append("insert into T_PUB_LIBRARYOUTMATERIAL(");
                strSqls.Append(strSqls1.ToString().Remove(strSqls1.Length - 1));
                strSqls.Append(")");
                strSqls.Append(" values (");
                strSqls.Append(strSqls2.ToString().Remove(strSqls2.Length - 1));
                strSqls.Append(")");
                strSqls.Append(";select @@IDENTITY");
                strArry.Add(strSqls);
            }
            #endregion

            #region 编辑出库单材料
            foreach (Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL item in editList)
            {
                StringBuilder strSqlm = new StringBuilder();
                strSqlm.Append("update T_PUB_LIBRARYOUTMATERIAL set ");
                if (item.LIBRARYOUTID != null)
                {
                    strSqlm.Append("LIBRARYOUTID='" + item.LIBRARYOUTID + "',");
                }
                else
                {
                    strSqlm.Append("LIBRARYOUTID= null ,");
                }
                if (item.MATERIAL_ID != null)
                {
                    strSqlm.Append("MATERIAL_ID=" + item.MATERIAL_ID + ",");
                }
                else
                {
                    strSqlm.Append("MATERIAL_ID= null ,");
                }
                if (item.MATERIAL_NAME != null)
                {
                    strSqlm.Append("MATERIAL_NAME='" + item.MATERIAL_NAME + "',");
                }
                else
                {
                    strSqlm.Append("MATERIAL_NAME= null ,");
                }
                if (item.NUM != null)
                {
                    strSqlm.Append("NUM=" + item.NUM + ",");
                }
                else
                {
                    strSqlm.Append("NUM= null ,");
                }
                if (item.MATERIAL_STATE != null)
                {
                    strSqlm.Append("MATERIAL_STATE='" + item.MATERIAL_STATE + "',");
                }
                else
                {
                    strSqlm.Append("MATERIAL_STATE= null ,");
                }
                if (item.TIMEIN != null)
                {
                    strSqlm.Append("TIMEIN='" + item.TIMEIN + "',");
                }
                else
                {
                    strSqlm.Append("TIMEIN= null ,");
                }
                int m = strSqlm.ToString().LastIndexOf(",");
                strSqlm.Remove(m, 1);
                strSqlm.Append(" where ID=" + item.ID + "");
                strArry.Add(strSqlm);
            }
            #endregion

            DBHelper.ExecuteSqlTran(strArry);
        }

        ///// <summary>
        ///// 通过申请单编号获取申请材料
        ///// </summary>
        ///// <param name="strWhere"></param>
        ///// <returns></returns>
        //public DataSet GetListByPid(string strWhere)
        //{

        //}


        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID)
        {
            Database db = DatabaseFactory.CreateDatabase();
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from T_PUB_LIBRARYOUTMATERIAL where ID=@ID ");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, ID);
            int cmdresult;
            object obj = db.ExecuteScalar(dbCommand);
            if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
            {
                cmdresult = 0;
            }
            else
            {
                cmdresult = int.Parse(obj.ToString());
            }
            if (cmdresult == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }



        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into T_PUB_LIBRARYOUTMATERIAL(");
            strSql.Append("LIBRARYOUTID,MATERIAL_ID,MATERIAL_NAME,NUM,MATERIAL_STATE,RETURN_NUM,DISCARD_ID,TIMEIN,REMARK)");

            strSql.Append(" values (");
            strSql.Append("@LIBRARYOUTID,@MATERIAL_ID,@MATERIAL_NAME,@NUM,@MATERIAL_STATE,@RETURN_NUM,@DISCARD_ID,@TIMEIN,@REMARK)");
            strSql.Append(";select @@IDENTITY");
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "LIBRARYOUTID", DbType.String, model.LIBRARYOUTID);
            db.AddInParameter(dbCommand, "MATERIAL_ID", DbType.Int32, model.MATERIAL_ID);
            db.AddInParameter(dbCommand, "MATERIAL_NAME", DbType.String, model.MATERIAL_NAME);
            db.AddInParameter(dbCommand, "NUM", DbType.Double, model.NUM);
            db.AddInParameter(dbCommand, "MATERIAL_STATE", DbType.String, model.MATERIAL_STATE);
            db.AddInParameter(dbCommand, "RETURN_NUM", DbType.Double, model.RETURN_NUM);
            db.AddInParameter(dbCommand, "DISCARD_ID", DbType.Int32, model.DISCARD_ID);
            db.AddInParameter(dbCommand, "TIMEIN", DbType.DateTime, model.TIMEIN);
            db.AddInParameter(dbCommand, "REMARK", DbType.String, model.REMARK);
            int result;
            object obj = db.ExecuteScalar(dbCommand);
            if (!int.TryParse(obj.ToString(), out result))
            {
                return 0;
            }
            return result;
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_PUB_LIBRARYOUTMATERIAL set ");
            strSql.Append("LIBRARYOUTID=@LIBRARYOUTID,");
            strSql.Append("MATERIAL_ID=@MATERIAL_ID,");
            strSql.Append("MATERIAL_NAME=@MATERIAL_NAME,");
            strSql.Append("NUM=@NUM,");
            strSql.Append("MATERIAL_STATE=@MATERIAL_STATE,");
            strSql.Append("RETURN_NUM=@RETURN_NUM,");
            strSql.Append("DISCARD_ID=@DISCARD_ID,");
            strSql.Append("TIMEIN=@TIMEIN,");
            strSql.Append("REMARK=@REMARK");
            strSql.Append(" where ID=@ID ");
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, model.ID);
            db.AddInParameter(dbCommand, "LIBRARYOUTID", DbType.String, model.LIBRARYOUTID);
            db.AddInParameter(dbCommand, "MATERIAL_ID", DbType.Int32, model.MATERIAL_ID);
            db.AddInParameter(dbCommand, "MATERIAL_NAME", DbType.String, model.MATERIAL_NAME);
            db.AddInParameter(dbCommand, "NUM", DbType.Double, model.NUM);
            db.AddInParameter(dbCommand, "MATERIAL_STATE", DbType.String, model.MATERIAL_STATE);
            db.AddInParameter(dbCommand, "RETURN_NUM", DbType.Double, model.RETURN_NUM);
            db.AddInParameter(dbCommand, "DISCARD_ID", DbType.Int32, model.DISCARD_ID);
            db.AddInParameter(dbCommand, "TIMEIN", DbType.DateTime, model.TIMEIN);
            db.AddInParameter(dbCommand, "REMARK", DbType.String, model.REMARK);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from T_PUB_LIBRARYOUTMATERIAL ");
            strSql.Append(" where ID=@ID ");
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, ID);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL GetModel(int ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,LIBRARYOUTID,MATERIAL_ID,MATERIAL_NAME,NUM,MATERIAL_STATE,RETURN_NUM,DISCARD_ID,TIMEIN,REMARK from T_PUB_LIBRARYOUTMATERIAL ");
            strSql.Append(" where ID=@ID ");
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, ID);
            Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,LIBRARYOUTID,MATERIAL_ID,MATERIAL_NAME,NUM,MATERIAL_STATE,RETURN_NUM,DISCARD_ID,TIMEIN,REMARK ");
            strSql.Append(" FROM T_PUB_LIBRARYOUTMATERIAL ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            Database db = DatabaseFactory.CreateDatabase();
            return db.ExecuteDataSet(CommandType.Text, strSql.ToString());
        }

        /// <summary>
        /// 获得数据列表（比DataSet效率高，推荐使用）
        /// </summary>
        public List<Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL> GetListArray(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,LIBRARYOUTID,MATERIAL_ID,MATERIAL_NAME,NUM,MATERIAL_STATE,RETURN_NUM,DISCARD_ID,TIMEIN,REMARK ");
            strSql.Append(" FROM T_PUB_LIBRARYOUTMATERIAL ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL> list = new List<Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL>();
            Database db = DatabaseFactory.CreateDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
                while (dataReader.Read())
                {
                    list.Add(ReaderBind(dataReader));
                }
            }
            return list;
        }


        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL ReaderBind(IDataReader dataReader)
        {
            Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL model = new Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL();
            object ojb;
            ojb = dataReader["ID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ID = (int)ojb;
            }
            model.LIBRARYOUTID = dataReader["LIBRARYOUTID"].ToString();
            ojb = dataReader["MATERIAL_ID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.MATERIAL_ID = (int)ojb;
            }
            model.MATERIAL_NAME = dataReader["MATERIAL_NAME"].ToString();
            ojb = dataReader["NUM"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.NUM = Convert.ToInt32(ojb);
            }
            model.MATERIAL_STATE = dataReader["MATERIAL_STATE"].ToString();
            ojb = dataReader["RETURN_NUM"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.RETURN_NUM = Convert.ToInt32(ojb);
            }
            ojb = dataReader["DISCARD_ID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.DISCARD_ID = (int)ojb;
            }
            ojb = dataReader["TIMEIN"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.TIMEIN = (DateTime)ojb;
            }
            model.REMARK = dataReader["REMARK"].ToString();
            return model;
        }

        #endregion  Method
    }
}
